package com.nikkerball.apps.darkhorse.dao.hibernate;

import com.nikkerball.apps.darkhorse.dao.BaseDao;
import com.nikkerball.apps.darkhorse.model.base.TouchableObject;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * The Base Data Access Object
 *
 * @author marius (created on 2010-12-12)
 */
public class BaseDaoHibernateImpl extends HibernateDaoSupport implements BaseDao {

    // ----- BaseDao -----

    public void add(String userName, TouchableObject touchableObject) {
        touchableObject.touch(userName);
        getHibernateTemplate().save(touchableObject);
    }

    public void delete(String userName, TouchableObject touchableObject) {
        touchableObject.touch(userName);
        getHibernateTemplate().delete(touchableObject);
    }

    public TouchableObject getById(Class aClass, String id) {
        return (TouchableObject) getHibernateTemplate().get(aClass, id);
    }

    public void update(String userName, TouchableObject touchableObject) {
        touchableObject.touch(userName);
        getHibernateTemplate().update(touchableObject);
    }
}
